package net.vil.framework.page;

import net.vil.framework.util.StringUtil;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * 
 * lotteryhk
 * @company jjtx nt .ltd
 * com.zx.mgr.page.PagerFactory.java
 * @author Administrator
 * 2010-8-12
 */
public class PagerFactory {
	private Log log=LogFactory.getLog(this.getClass());
	private final String DEFAULT_TYPE="SqlServer";
	private String dialect;
	
	public String getDialect() {
		return dialect;
	}

	public void setDialect(String dialect) {
		this.dialect = dialect;
	}

	public <T extends Object> Pager<T> getPager(Class<T> cls){
		if (log.isDebugEnabled()){log.debug("create pager with dialect="+dialect);}
		if (StringUtil.isEmpty(dialect)){
			dialect=DEFAULT_TYPE;
		}
		if ("mysql".equalsIgnoreCase(dialect)){
			return new MySqlPagerDialect<T>();
		}else if("oracle".equalsIgnoreCase(dialect)){
			return new OraclePagerDialect<T>();
		}else if("SqlServer".equalsIgnoreCase(dialect)){
			return new Sql2000PagerDialect<T>();
		}else{
			return new Sql2000PagerDialect<T>();
		}
	}
}
